package Text1;

import java.util.*;

public class Main {
    //    输入一个长度为 n的整数序列。接下来输入 m
//    个操作，每个操作包含三个整数 l,r,c，表示将序列中 [l,r]之间的每个数加上 c。
//    请你输出进行完所有操作后的序列。
    public static void main1(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt(), m = scanner.nextInt();
        int[] arr = new int[n + 2];
        int[] tmp = new int[n + 2];
        for (int i = 1; i <= n; i++) {
            arr[i] = scanner.nextInt();
        }
        for (int i = 1; i <= n; i++) {
            insert1(tmp, i, i, arr[i]);
        }

        while (m-- > 0) {
            int l = scanner.nextInt(), r = scanner.nextInt(), c = scanner.nextInt();
            insert1(tmp, l, r, c);
        }
        for (int t = 1; t <= n; t++) {
            tmp[t] += tmp[t - 1];
        }
        for (int i = 1; i <= n; i++) {
            System.out.print(tmp[i] + " ");
        }
    }

    public static void insert1(int[] arr, int l, int r, int c) {
        arr[l] += c;
        arr[r + 1] -= c;
    }


//    输入一个 n行 m 列的整数矩阵，再输入 q个操作，
//    每个操作包含五个整数 x1,y1,x2,y2,c，其中 (x1,y1)
//    和 (x2,y2)表示一个子矩阵的左上角坐标和右下角坐标。
//    每个操作都要将选中的子矩阵中的每个元素的值加上 c。
//    请你将进行完所有操作后的矩阵输出。

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt(), m = scanner.nextInt(),q = scanner.nextInt();
        int[][] arr = new int[n + 2][m + 2];
        int[][] tmp = new int[n + 2][m + 2];
        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= m; j++) {
                arr[i][j] = scanner.nextInt();
            }
        }
        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= m; j++) {
                insert2(tmp,i,j,i,j,arr[i][j]);
            }
        }
        while(q-->0){
            int x1 = scanner.nextInt(), y1 = scanner.nextInt(),
                    x2 = scanner.nextInt(),y2=scanner.nextInt(),c=scanner.nextInt();
            insert2(tmp,x1,y1,x2,y2,c);

        }
        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= m; j++) {
                tmp[i][j]+=tmp[i-1][j]+tmp[i][j-1]-tmp[i-1][j-1];
            }
        }


        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= m; j++) {
                System.out.print(tmp[i][j]+" ");
            }
            System.out.println();
        }
    }
    public static void insert2(int[][] arr, int x1, int y1,int x2,int y2, int c) {
        arr[x1][y1]+=c;
        arr[x2+1][y1]-=c;
        arr[x1][y2+1]-=c;
        arr[x2+1][y2+1]+=c;
    }
}
